<!--extend frame-->
<block_title>
    系统管理
</block_title>
<block_left>
    <a href="{{url SysNaples/Admin/sys/clean}}" class="list-group-item"><span class="glyphicon glyphicon-trash"><span class="hidden-xs bold"> 缓存清理</span></span></a>
    <a href="{{url SysNaples/Admin/sys/changePsw}}" class="list-group-item"><span class="glyphicon glyphicon-user"><span class="hidden-xs bold"> 修改密码</span></span></a>
    <a href="{{url SysNaples/Admin/sys/accessList}}" class="list-group-item"><span class="glyphicon glyphicon-list"><span class="hidden-xs bold"> 许可列表</span></span></a>
    <a href="{{url SysNaples/Admin/sys/webShell}}" class="list-group-item"><span class="glyphicon glyphicon-eye-open"><span class="hidden-xs bold"> web shell</span></span></a>
</block_left>
<block_right>
    {{if $action=='clean'}}
    <div class="panel panel-primary col-md-6 col-md-offset-3" style="padding: 0;margin-top: 100px">
        <div class="panel-heading">
            <h3 class="panel-title">请选择需要清理的项目 </h3>
        </div>
        <div class="panel-body">
            <form class="form-horizontal" role="form" action="{{url sysCleans based}}" method="post" onsubmit="if(!confirm('确定要执行清理操作吗？')){return false;}">
                <div class="btn-group-vertical" data-toggle="buttons" style="float: left">
                    {{each $cleans $k $v}}
                    <label class="btn btn-lg btn-primary btn-clean">
                        <input type="checkbox" name="cbxCleans[]" value="{{:k}}" autocomplete="off"> {{:v}}
                    </label>
                    {{/}}
                </div>
                <div class="btn-group-vertical" style="vertical-align: bottom;float: right">
                    <span class="btn btn-lg btn-info" onclick="$('.btn-clean.active').click();$('.btn-clean').click()">全选</span>
                    <span class="btn btn-lg btn-info" onclick="$('.btn-clean.active').click()">全不选</span>
                    <span class="btn btn-lg btn-info" onclick="$('.btn-clean').click()">反选</span>
                    <input type="submit" class="btn btn-lg btn-info" onclick="">
                </div>
                {{token sys-cleans}}
            </form>
        </div>
        <div class="panel-footer">清理后不可撤销，请慎重选择</div>
    </div>
    {{elseif $action=='changePsw'}}
        <div style="margin-top: 100px" class="hidden-xs"></div>
        <div class="col-md-8 col-lg-8 col-md-offset-2 col-lg-offset-2">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h3 class="panel-title">改变Naples管理员密码 </h3>
                </div>
                <div class="panel-body">
                    <form class="form-horizontal" role="form" action="{{url sysChangePsw based}}" method="post" id="formPsw">
                        <div class="form-group">
                            <label for="inputPassword1" class="col-sm-2 control-label">新密码</label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control" id="inputPassword1" placeholder="Password" name="psw1">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPassword2" class="col-sm-2 control-label">重复</label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control" id="inputPassword2" placeholder="Password" name="psw2">
                            </div>
                        </div>
                        {{token sys-cleans}}
                        <div class="form-group" style="margin-top: 50px">
                            <div class="col-md-3 pull-right">
                                <input class="btn btn-primary btn-lg disabled" type="submit" id="btnSubPsw">
                            </div>
                        </div>
                    </form>
                    <script>
                        function checkPsw() {
                            var v1=$('#inputPassword1').val();
                            var v2=$('#inputPassword2').val();
                            if (v1!=v2 || v1==''){
                                $("#btnSubPsw").addClass('disabled').val('提交');
                            }else{
                                $("#btnSubPsw").removeClass('disabled').val('提交');
                            }
                        }
                        $('#formPsw').on('submit',function () {
                            if ($("#btnSubPsw").hasClass('disabled')){
                                return false;
                            }
                        });
                        setInterval(checkPsw,1000);
                    </script>
                </div>
                <div class="panel-footer">忘记密码？你可以在某个文件找到该字符的md5值的保存位置</div>
            </div>
        </div>

    {{elseif $action=='accessList'}}
    {{* 黑白名单}}
        <div class="row" style="margin-bottom: 20px;margin-top: 20px">
            <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
                <div class="alert alert-info">当前模式：{{:modetype}}</div>
            </div>
            <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
                <button class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModa2">切换模式</button>
                <!-- 按钮触发模态框 -->
                <button class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">添加条目</button>
                <a href="{{urlSelf}}" class="btn btn-info btn-lg">刷新列表</a>
            </div>
        </div>
        <div class="row">
            <div class="col-md-6">
                <div class="panel panel-primary" >
                    <div class="panel-heading">
                        <h3 class="panel-title">白名单</h3>
                    </div>
                    <div style="height: 450px;overflow: auto">
                        <table class="table table-striped table-hover" >
                            <tr>
                                <th>IP</th>
                                <th>失效期</th>
                                <th>备注</th>
                                <th>操作</th>
                            </tr>
                            {{if $whiteList}}
                            {{each $whiteList}}
                            <tr>
                                <td>{{:k}}</td>
                                <td>{{:v.exp |date}}</td>
                                <td>{{:v.info}}</td>
                                <td><button class="btn-xs btn-primary"><span class="glyphicon glyphicon-trash btn-white" ip="{{:k}}"></span></button></td>
                            </tr>
                            {{/}}
                            {{/}}
                        </table>
                    </div>
                </div>
            </div>
            <div class="col-md-6">
                <div class="panel panel-primary" >
                    <div class="panel-heading">
                        <h3 class="panel-title">黑名单</h3>
                    </div>
                    <div style="height: 450px;overflow: auto">
                        <table class="table table-striped table-hover">
                            <tr>
                                <th>IP</th>
                                <th>失效期</th>
                                <th>备注</th>
                                <th>操作</th>
                            </tr>
                            {{if $blackList}}
                            {{each $blackList}}
                            <tr>
                                <td>{{:k}}</td>
                                <td>{{:v.exp |date}}</td>
                                <td>{{:v.info}}</td>
                                <td><button class="btn-xs btn-primary"><span class="glyphicon glyphicon-trash btn-black" ip="{{:k}}"></span></button></td>
                            </tr>
                            {{/}}
                            {{/}}
                        </table>
                    </div>
                </div>
            </div>
        </div>

    <!-- 模态框（Modal） -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">添加条目</h4>
                </div>
                <div class="modal-body">
                    <form action="{{url sysAddList based}}" method="post" class="form-horizontal" role="form">
                        <div class="form-group">
                            <label  class="col-sm-3 control-label" style="cursor: pointer" onclick="$('#ipt_ip').val('{{:ip}}')">IP</label>
                            <div class="col-sm-9">
                                <input type="text" id="ipt_ip" name="ip" class="form-control"  placeholder="待加入名单的IP值">
                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-sm-3 control-label">备注</label>
                            <div class="col-sm-9">
                                <input type="text" name="info" class="form-control" placeholder="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-sm-3 control-label">有效期(分钟)</label>
                            <div class="col-sm-9">
                                <input type="text" name="exp" class="form-control"  placeholder="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-sm-3 control-label">添加到</label>
                            <div class="col-sm-9">
                                <div class="radio radio-inline">
                                    <label>
                                        <input type="radio" name="list"  value="white" checked>白名单
                                    </label>
                                </div>
                                <div class="radio radio-inline">
                                    <label>
                                        <input type="radio" name="list"  value="black">黑名单
                                    </label>
                                </div>
                            </div>

                        </div>
                        <div class="form-group" style="margin-top: 50px">
                            <button type="submit" class="btn btn-primary col-md-3 col-md-offset-8">提交</button>
                        </div>

                    </form>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
    <!-- 模态框（Modal） -->
    <div class="modal fade" id="myModa2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" >切换模式</h4>
                </div>
                <div class="modal-body">
                    <h4>当前模式：{{:modetype}}</h4>
                    <button type="button" class="btn btn-info btn-switch-mode" value="free">无限制</button>
                    <button type="button" class="btn btn-info btn-switch-mode" value="white">白名单</button>
                    <button type="button" class="btn btn-info btn-switch-mode" value="black">黑名单</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
    <script>
        var btnWs=$('.btn-white');
        var btnBs=$('.btn-black');
        btnWs.click(function () {
            delListItem('white',$(this).attr('ip'),$(this))
        });
        btnBs.click(function () {
            delListItem('black',$(this).attr('ip'),$(this))
        });
        function delListItem(type,ip,dom) {
            $.ajax({
                type: "POST",
                url: "{{url sysDelAccessList based}}",
                data: {
                    type:type,
                    ip:ip
                },
                dataType: "json",
                async:false,
                success:function (data) {
                    dom.parents('tr').remove()
                },
                error:function () {
                    alert('error');
                }
            })
        }
        $('.btn-switch-mode').click(function () {
            var type=$(this).val();
            $.ajax({
                type: "POST",
                url: "{{url sysSwitchAccessList based}}",
                data: {
                    type:type
                },
                dataType: "json",
                async:false,
                success:function (data) {
                    window.location.reload();
                },
                error:function () {
                    alert('error');
                }
            })
        });
    </script>
    {{elseif $action=='webShell'}}
        <iframe src="{{url SysNaples/Admin/webShell}}" style="overflow-y: scroll;overflow-x: hidden;width: 100%;height:660px;" frameborder="0" ></iframe>
    {{else}}
    <div class="container">
        <div class="jumbotron" style="background-color: inherit">
            <h2>系统全局管理</h2>
            <p>请于左侧选择一项功能。</p>
        </div>
    </div>
    {{/}}

</block_right>
<block_bottom>

</block_bottom>
